import { ref } from "vue"
import useLoading from "./useLoading"
export default (request) => {
    const { isError, isLoading } = useLoading()
    const data = ref(null)
    request
        .then(res => {
            if (res.code == 200) {
                data.value = res.data
                isLoading.value = false
            } else {
                isError.value = true
                isLoading.value = false
            }
        })
        .catch(res => {
            isError.value = true
            isLoading.value = false
        })

    return {
        isError,
        isLoading,
        data
    }
}